package br.com.lambdacore.validator.impl;

public class ClassValidator extends ValidatorImpl<Class<?>> {

	protected ClassValidator(Class<?> clazz) {
		super(clazz);
	}

	// public boolean instanceOf(Class<?> other) {
	// Class<?> clazz = this.getObject();
	//
	// while (is(clazz).notNil()) {
	// if (is(clazz).notEqualThan(other)) {
	// clazz = clazz.getSuperclass();
	// } else {
	// return true;
	// }
	// }
	//
	// return false;
	// }

	@Override
	public boolean instanceOf(Class<?> other) {
		Class<?> clazz = this.getObject();
		return clazz.isInstance(other);
	}

	@Override
	public boolean notInstanceOf(Class<?> other) {
		return !this.instanceOf(other);
	}

	public static ClassValidator is(Class<?> clazz) {
		return new ClassValidator(clazz);
	}

}
